package com.hc.util;



import java.sql.Connection;
import java.sql.Statement;









public class BaseSql {

	
	public static String ip="192.168.0.149";
	public static String userName="sa";
	public static String pwd="hc2oo8hc@hc2008hc";
	public static String port="1433";
	
//	public static String ip="127.0.0.1";
//	public static String userName="root";
//	public static String pwd="a122334";
//	public static String port="3306";
	public static String DataName= "speedTest";
	public Connection  con;
	public Statement sta;
	
	
public void openConnect() {
    try
    {

//      java.lang.Class.forName("org.gjt.mm.mysql.Driver");
//      
//
//      String strCon = "jdbc:mysql://"+ ip+":"+port+"/"+DataName;
      
    	
    	  java.lang.Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
          String strCon = "jdbc:sqlserver://"+ ip+":"+port+";databaseName="+DataName;
    	
          
//          
//      java.lang.Class.forName("org.gjt.mm.mysql.Driver");
//      String strCon = "jdbc:mysql://"+ ip+":"+port+"/"+DataName;
      
      String strUserName = userName;   
      String strPWD = pwd;          
      

      	con = java.sql.DriverManager.getConnection(strCon, strUserName, strPWD);
      

      sta = con.createStatement();
      sta.setQueryTimeout(30);   
      

    
   
    }

    catch (java.lang.ClassNotFoundException cnfe)
    {
    	cnfe.printStackTrace();
       System.out.println(cnfe.getMessage());
    }
    catch (java.sql.SQLException se)
    {
    	se.printStackTrace();
       System.out.println(se.getMessage());
    }

}

public static void main(String[] args) {
	BaseSql d = new BaseSql();
	d.openConnect();
}

}
